//
//  UserVC.swift
//  DollarBuy
//
//  Created by 郑东喜 on 2016/11/7.
//  Copyright © 2016年 郑东喜. All rights reserved.
//

import UIKit



class UserVC: MeBaseViewController {
    
    static let shareInstance = UserVC()
    
    
    @IBAction func xgPassSEL(_ sender: UIButton) {
        self.navigationController?.pushViewController(ChangePassVC(), animated: true)
    }
    
    //用户名
    @IBOutlet weak var tfNum: UITextField!
    //密码
    @IBOutlet weak var tfPass: UITextField!
    

}

// MARK:- 加载本地数据
extension UserVC {
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        //加载本地 用户名
        if localSave.object(forKey: localName) as? String != nil {
            self.tfNum.text = localSave.object(forKey: localName) as? String
        } else {
            return
        }
        
        //加载本地 用户名密码
        if localSave.object(forKey: localPass) as? String != nil {
            self.tfPass.text = localSave.object(forKey: localPass) as? String
        } else {
            return
        }
    }
    
}

// MARK:- 跳转接口
extension UserVC {
    //qq登录
    @IBAction func qqLogin(_ sender: UIButton) {
        print("\((#file as NSString).lastPathComponent):(\(#line)):(\("qq登录")))")
        UserTool.shared.alert(msg: "正在努力开发中...")
    }
    
    //微信登录
    @IBAction func wechatLogin(_ sender: UIButton) {
        print("\((#file as NSString).lastPathComponent):(\(#line)):(\("微信登录")))")
        UserTool.shared.alert(msg: "正在努力开发中...")
    }
    
    
    /** 错误提示
     恭喜您登录成功
     缺少手机号参数
     帐号与密码不匹配
     */
    //登录
    @IBAction func loginSEL(_ sender: UIButton) {
        
        self.login(tfNum: self.tfNum, tfPass: self.tfPass)

    }
    
    //注册
    @IBAction func rigSEL(_ sender: UIButton) {
        self.navigationController?.pushViewController(RigisterVC(), animated: true)
        print("\((#file as NSString).lastPathComponent):(\(#line)):(\("跳转注册成功")))")
    }
    
    //重置密码
    @IBAction func resetSEL(_ sender: UIButton) {
        self.navigationController?.pushViewController(ForgetVC(), animated: true)
        print("\((#file as NSString).lastPathComponent):(\(#line)):(\("跳转重置密码成功")))")
    }

}


